import {actionTypes} from "./actions";

const INITIAL_STATE = {
    userToken: null, //存储登录的token
    map: null, //存储经纬度
    getData: [],
    setClassDate: '', //默认时间
    searchTitle: '',
    regionIds: '',
    areaIds: '', //市区域id 用于切换城市
    oneAdcodeName: '',
    oneAdcodeCode: '',
    adcodeCode: '',
    adcodeName: '',
    backPage: '',
    gainCourse: '',
    peopleStatus: false, //新人优惠券弹窗 状态判断
    mobileFlag: 0, //判断是否授权手机号 0未授权 1授权
    existUser: 0, //判断是否授权用户信息 0未授权 1授权
}

export default function Reducers (state = INITIAL_STATE, action) {
    switch (action.type) {
        case actionTypes.SETUSERTOKEN:
            let {userToken} = action.payload;
            return {
                ...state,
                userToken
            };
            break;
        case actionTypes.SETMAP:
            let {map} = action.payload;
            return {
                ...state,
                map
            };
        case actionTypes.TYPEDATA:
            let {getData} = action.payload;
            return {
                ...state,
                getData
            };
        case actionTypes.GETCLASSDATE:
            let {setClassDate} = action.payload;
            return {
                ...state,
                setClassDate
            };
        case actionTypes.SEARCHTITLE:
            let {searchTitle} = action.payload;
            return {
                ...state,
                searchTitle
            };
        case actionTypes.REGIONID:
            let {regionIds} = action.payload;
            return {
                ...state,
                regionIds
            };
        case actionTypes.AREAID:
            let {areaIds} = action.payload;
            return {
                ...state,
                areaIds
            };
        case actionTypes.ONEADCODESCODE:
            let {oneAdcodeCode} = action.payload;
            return {
                ...state,
                oneAdcodeCode
            };
        case actionTypes.ONEADCODESNAME:
            let {oneAdcodeName} = action.payload;
            return {
                ...state,
                oneAdcodeName
            };
        case actionTypes.ADCODESCODE:
            let {adcodeCode} = action.payload;
            return {
                ...state,
                adcodeCode
            };
        case actionTypes.ADCODESNAME:
            let {adcodeName} = action.payload;
            return {
                ...state,
                adcodeName
            };
        case actionTypes.BACKPAGE:
            let {backPage} = action.payload;
            return {
                ...state,
                backPage
            };
        case actionTypes.GAINCOURSE:
            let {gainCourse} = action.payload;
            return {
                ...state,
                gainCourse
            };
        case actionTypes.SETPEOPLE:
            let {peopleStatus} = action.payload;
            return {
                ...state,
                peopleStatus
            };
        case actionTypes.MOBILEFLAG:
            let {mobileFlag} = action.payload;
            return {
                ...state,
                mobileFlag
            };
        case actionTypes.EXISUSER:
            let {existUser} = action.payload;
            return {
                ...state,
                existUser
            };
        default:
            return state
    }
}
